Public Class NPersonal
    'agrega un tutor a la bbd
    Public Function cargarPersonal(ByVal personal As Entidades.EPersonal) As Boolean
        'utiliza la capa de datos
        Dim oDatos As New Datos.DPersonal
        Dim oPersonal As New List(Of Entidades.EPersonal)
        Dim band As Boolean
        Try
            If oDatos.existeLegajoDePersonal(personal) Then
                band = False
                Exit Try
            End If
            oPersonal = oDatos.buscarPersonalPorDni(personal, True)
            If oPersonal.Count > 0 Then
                band = False
                Exit Try
            End If
            oDatos.cargarPersonal(personal)
            band = True
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
        Return band
    End Function

    Public Sub modificarPersonal(ByVal personal As Entidades.EPersonal)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            oDatos.modificarPersonal(personal)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Sub

    Public Sub borrarPersonal(ByVal personal As Entidades.EPersonal)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            oDatos.borrarPersonal(personal)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Sub

    'SOBRECARGADO: busca personal por apellido y condicion
    Public Function buscarPersonal(ByVal apellido As String, ByVal condicion As Boolean)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonal(apellido, condicion)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    'SOBRECARGADO: busca todo el personal
    Public Function buscarPersonal() As List(Of Entidades.EPersonal)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonal()
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    'SOBRECARGADO: busca personal por legajo
    Public Function buscarPersonal(ByVal oPersonal As Integer) As Entidades.EPersonal
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonal(oPersonal)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    'SOBRECARDADO: busca personal por legajo y condicion
    Public Function buscarPersonal(ByVal legajo As Integer, ByVal cond As Boolean)
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonal(legajo, cond)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    Public Function buscarPersonalPorAsignatura(ByVal asig As String) As List(Of Entidades.EPersonal)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonalPorAsignatura(asig)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    Public Function buscarPersonalPorAsignaturaPorCurso(ByVal curso As Entidades.ECurso) As List(Of Entidades.EPersonal)
        'utiliza la capa de datos
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            Return oDatos.buscarPersonalPorAsignaturaPorCurso(curso)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    Public Function buscarPersonal(ByVal condicion As Boolean) As List(Of Entidades.EPersonal)
        'utiliza la capa de fdatos para esta operacion
        Dim oCnn As New Datos.DConexion
        Dim oDatos As New Datos.DPersonal
        Try
            'crea instancia de la clase contactos para realizar 
            'operacion y delegar contactos
            Return oDatos.buscarPersonal(condicion)
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            oDatos = Nothing
        End Try
    End Function

    'Public Function buscarPersonalPorLegajo(ByVal oPersonal As Entidades.EPersonal)
    '    'utiliza la capa de datos para esta operacion
    '    Dim oCnn As New Datos.DConexion
    '    Dim oDatos As New Datos.DPersonal
    '    Try
    '        Return oDatos.buscarPersonal(oPersonal)
    '    Catch ex As Exception
    '        Throw New ArgumentException(ex.Message)
    '    Finally
    '        oDatos = Nothing
    '    End Try
    'End Function
    Public Function datosComboPersonal() As List(Of Entidades.EPersonal)
        Dim ocnn As New Datos.DConexion
        Dim odatos As New Datos.DPersonal
        Try
            Return odatos.datosComboPersonal()
        Catch ex As Exception
            Throw New ArgumentException(ex.Message)
        Finally
            odatos = Nothing
        End Try
    End Function

End Class
